<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
	<script src="lib/react.development.js"></script>
	<script src="lib/react-dom.development.js"></script>
	<script src="lib/babel.min.js"></script>
</head>
<body>
<div id="root"></div>
</body>
<script type="text/babel">
	// 通过属性进行参数的传递。
	const root = ReactDOM.createRoot(document.querySelector("#root"));
	React.Component.prototype.username = "wangwu"
	class App extends React.Component{
		render(){
			// console.log("app",this.username);// wangwu
			return (
				<div>
					<h3>App</h3>
					<Child age={1} sex={"男"}/>
				</div>
			)
		}
	}
	// 子组件接收的属性全部都在this.props对象中
	class Child extends React.Component{
		constructor(props) {
			super(props);
			// console.log(props === this.props);// true
			// this.setState({
			// 	sex:this.props.sex,
			// 	age:this.props.age
			// })
		}
		render(){
			// console.log("Child",this.username);// wangwu
			const {age,sex} = this.props;
			this.props.age = 122;
			return (
				<div>
					<h3>Child</h3>
					<p>age:{this.props.age}|{age}</p>
					<p>sex:{this.props.sex}|{sex}</p>
				</div>
			)
		}
	}
	root.render(<App/>);
</script>
</html>